package com.xiaoai.juc;

import org.junit.Test;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author
 * @Date 2021-09-21 21:50
 */
public class CallableDemo {

   public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> futureTask = new FutureTask<>(new MyThread());
        new Thread(futureTask).start();

        Integer res = futureTask.get();
        System.out.println(res);

    }
}

class MyThread implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {

        System.out.println("call()...");
        return 1024;
    }
}
